// 右最顶上角的时间组件
function showtime() {
  var today, hour, second, minute, year, month, date;
  var strDate;
  today = new Date();
  // console.log("today---", today);
  var n_day = today.getDay();
  switch (n_day) {
    case 0:
      {
        strDate = "星期日";
      }
      break;
    case 1:
      {
        strDate = "星期一";
      }
      break;
    case 2:
      {
        strDate = "星期二";
      }
      break;
    case 3:
      {
        strDate = "星期三";
      }
      break;
    case 4:
      {
        strDate = "星期四";
      }
      break;
    case 5:
      {
        strDate = "星期五";
      }
      break;
    case 6:
      {
        strDate = "星期六";
      }
      break;
    case 7:
      {
        strDate = "星期日";
      }
      break;
  }
  year = today.getFullYear();
  // console.log('year--', year)
  month = today.getMonth() + 1;
  date = today.getDate();
  hour = today.getHours();
  minute = today.getMinutes();
  second = today.getSeconds();
  if (month < 10) month = "0" + month;
  if (date < 10) date = "0" + date;
  if (hour < 10) hour = "0" + hour;
  if (minute < 10) minute = "0" + minute;
  if (second < 10) second = "0" + second;
  document.getElementById("time").innerHTML =
    year +
    "年" +
    month +
    "月" +
    date +
    "日 " +
    strDate +
    " " +
    hour +
    ":" +
    minute +
    ":" +
    second; // 显示时间
  setTimeout("showtime();", 1000); // 设定函数自动执行时间为 1000 ms(1 s)
}

function formatSeconds(value) {
  var theTime1 = parseInt(value); // 需要转换的时间分钟
  var theTime2 = 0; // 小时
  var theTime3 = 0; // 天

  if (theTime1 > 60) {
    theTime2 = parseInt(theTime1 / 60);
    theTime1 = parseInt(theTime1 % 60);
    if (theTime2 > 24) {
      // 大于24小时
      theTime3 = parseInt(theTime2 / 24);
      theTime2 = parseInt(theTime2 % 24);
    }
  }
  var result = "";
  if (theTime1 > 0) {
    result = "" + parseInt(theTime1) + "分钟";
  }
  if (theTime2 > 0) {
    result = "" + parseInt(theTime2) + "小时" + result;
  }
  if (theTime3 > 0) {
    result = "" + parseInt(theTime3) + "天" + result;
  }
  return result;
}
